<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2014 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Tuolaji <479923197@qq.com>
// +----------------------------------------------------------------------
namespace Api\Controller;

use Common\Controller\AppframeController;

header('Content-Type: text/plain; charset=utf-8');
class ReleaseController extends AppframeController{


	//自荐添加 保存
	function  release_zijian_sav(){
		$uid = I("uid");
//		$uid = 1;
		$lable = I("lable");      //传字符串
		$img = I("images");   //传字符串
//		$imgs = "https://q.qlogo.cn/qqapp/1106568601/760CA2A58C135474E9A02EEC47A161FF/100" ;
		if(!$uid || !$lable || !$img){
			exit(json_encode(array('status'=>'10003','data'=>'缺少参数')));
		}else{
			$dat['account_id'] = $uid;
			$dat['cover_lable_id'] = $lable;
			$dat['images'] = $img;
			$dat['is_del'] = 0;
			$dat['ctime'] = time();
			M("cover")->add($dat);
			exit(json_encode(array('status'=>'200','data'=>"添加成功")));
		}
	}

	  //进入发布通告的页面  进行判断
	function release_tonggao_add(){
		$uid = I("uid");

		if(!$uid){
			exit(json_encode(array('status'=>'10003','data'=>'缺少参数')));
		}else{
			$data = M("account")->where("id = $uid")->field("id,is_renzheng,is_member")->find();
		}

		$tonggao = M("tonggao")->where("account_id={$uid} and is_del = 0")->select();
		if($data['is_renzheng']==1){
			     if($data['is_member']==1){
					    if(count($tonggao)<5){
							exit(json_encode(array('status'=>'200','data'=>'发布成功')));
						}else{
							exit(json_encode(array('status'=>'205','data'=>'会员只可添加五条通告')));
						}
				 }else{
					 if(count($tonggao)>=1){
						 exit(json_encode(array('status'=>'204','data'=>'非会员只可添加一条通告')));
					 }else{
						   exit(json_encode(array('status'=>'200','data'=>'发布成功')));
					 }
				 }
		}else{
			exit(json_encode(array('status'=>'203','data'=>'该用户未认证，不可以发布通告')));
		}


	}
	//通告添加 保存
	function  release_tonggao_sav(){
		$uid = I("uid");
//		$uid = 1;
		$tonggao_lable = I("tonggao_lable_id"); //标签
//

		$name = trim(I("name"));      //通告名称
//		$name = "招聘演员" ;
		$stime = I("stime");     //通告的开始时间
//		$stime =  time();
		$etime = I("etime");     //通告的结束时间
//		$etime =  time();
		$feiyong = trim(I("feiyong"));  //费用
//		$feiyong = "268";
		$sex = trim(I("sex"));   //性别
//		$sex = "男";
		$address = trim(I("address")); //地址
//		$address = "河北";
		$renshu = trim(I("renshu"));        //人数
//		$renshu = 10;
		$contacts = trim(I("contacts"));    // 联系人
//		$contacts = "赵小杰";
		$phone = trim(I("phone"));           //联系电话
//		$phone = "13910655615";
		$details = trim(I("details"));   //工作详情
//		$details = "北京群星表演艺术学校1995年由著名演员吕丽萍创办，是经北京市石景山区教委批准的专门培养影视剧表演人才和其它艺术人才的艺术学校";
		$height_s = trim(I("s_hight"));   //身高 的开始
//		$height_s = "170";
		$height_e = trim(I("e_hight"));   //身高的结束
//		$height_e = "185";
		$ctime = time();

		if(!$uid || !$name || !$stime || !$etime || !$feiyong || !$address || !$renshu || !$contacts || !$phone || !$details ){
			exit(json_encode(array('status'=>'10003','data'=>'缺少参数')));
		}else{
			$dat['account_id'] = $uid;
			$dat['name'] = $name;

			$dat['tonggao_biaoqian'] =  $tonggao_lable;

			$dat['sex'] = $sex;

			$dat['is_del'] = 0;
			$dat['ctime'] = $ctime;
			$dat['shuaxin_times'] = time();
			$dat['stime'] =  $stime;
			$dat['etime'] =  $etime;
			$dat['baochou'] =  $feiyong;
			$dat['address'] =  $address;
			$dat['renshu'] =  $renshu;
			$dat['contacts'] =  $contacts;
			$dat['phone'] =  $phone;
			$dat['details'] =  $details;
			$dat['height_s'] =  $height_s;
			$dat['height_e'] =  $height_e;

		    M("tonggao")->add($dat);
			exit(json_encode(array('status'=>'200','data'=>'添加成功')));
		}
	}






}